<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Vue指令v-for</title>
    <script src="js/vue.js"></script>
</head>
<body>

<!--2.编写视图-->
<div id="app">
	<!-- 固定循环次数 -->
    <div v-for="i in 5">{{i}}</div>
    <hr/>

	<!-- 遍历普通数组语法 -->
    <ul>
        <li v-for="name in names">{{name}}</li>
    </ul>
    <hr/>

	<!-- 遍历对象数组 -->
    <ul>
        <li v-for="person in persons">
            姓名: {{person.name}} ,年龄: {{person.age}}
        </li>
    </ul>
    <hr/>

	<!-- 遍历对象数组带索引 -->
    <ul>
        <li v-for="(person, index) in persons">
            编号: {{index+1}} ,姓名: {{person.name}} ,年龄: {{person.age}}
        </li>
    </ul>
</div>

<script>
    // 1.创建Vue对象, el找到vue操作的的标签, data是vue中的数据
    new Vue({
        el: "#app",
        data: {
            names: ["Jack", "Rose", "Tony", "Tom"],
            persons: [
                {
                    name: "孙悟空",
                    age: 501
                },{
                    name: "猪八戒",
                    age: 301
                },{
                    name: "沙悟净",
                    age: 201
                }
            ]
        }
    });
</script>
</body>
</html>